package com.obas.flex.common.proxy {
   import com.ease.util.events.MethodReturnEvent;
   import com.ease.util.proxies.BaseProxy;

   public class DefaultServiceProxy extends BaseProxy {
      public function DefaultServiceProxy(serviceName:String, channelUri:String=null, secure:Object=null) {
         super(serviceName, channelUri, secure);
      }

     override public function callService(methodName:String, arguments:Array,
                                 callback:Function=null, callContext:Object=null):void {
        if (_enabled) {
           super.callService(methodName, arguments, callback, callContext);
        }
        else {
           if (callback != null) {
              var returnEvent:MethodReturnEvent =
                 MethodReturnEvent.newResultEvent(null, callContext);
              callback(returnEvent);
           }
        }
     }

    private var _enabled:Boolean = true;
    /**
     * If <code>enabled</code> is <code>false</code>, all client requests will be
     * blocked. And a null MethodReturnEvent will <code>null</code> result will be
     * returned.
     */
    public function get enabled():Boolean {
       return _enabled;
    }

    public function set enabled(value:Boolean):void {
       if (_enabled != value) {
          _enabled = value;
       }
    }
   }
}